using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Magiq.Databases.Delete;
using Magiq.Databases.Insert;
using Magiq.Databases.Query;
using Magiq.Databases.Update;
using Magiq.Delete;
using Magiq.Insert;
using Magiq.Query;
using Magiq.Support;
using Magiq.Update;

namespace Magiq.Databases
{
    public interface IOrmAdapter
    {
        IDbCommand GetSelectCommand(IQueryable queryable);
        ITypeMapping GetMappingOf(Type type);
        IEnumerable<DatabaseDelete<T>> BuildDatabaseDeletes<T>(IDelete<T> delete) where T : class;
        IEnumerable<DatabaseUpdate<T>> BuildDatabaseUpdates<T>(IUpdate<T> update) where T : class;

        IEnumerable<DatabaseInsert<TSource>> BuildDatabaseInserts<TSource, TDestination, TNew>(
            IInsert<TSource, TDestination, TNew> insert);

        IInsertDestination<TNew> GetInsertDestination<TSource, TDestination, TNew>(
            IInsert<TSource, TDestination, TNew> insert)
            where TDestination : class
            where TNew : class, TDestination, new();

        IDbConnection GetConnection();
        IDialect Dialect { get; }
        IQueryable<TChild> GetQueryableFrom<T, TChild>(QueryInfo<T, TChild> queryInfo) where T : class;
    }
}